import 'package:nyh_motorcade_app/entity/company_info_entity.dart';

companyInfoEntityFromJson(CompanyInfoEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['createTime'] != null) {
		data.createTime = json['createTime'].toString();
	}
	if (json['createUser'] != null) {
		data.createUser = json['createUser'].toString();
	}
	if (json['createUserId'] != null) {
		data.createUserId = json['createUserId'].toString();
	}
	if (json['updateTime'] != null) {
		data.updateTime = json['updateTime'].toString();
	}
	if (json['updateUser'] != null) {
		data.updateUser = json['updateUser'].toString();
	}
	if (json['updateUserId'] != null) {
		data.updateUserId = json['updateUserId'].toString();
	}
	if (json['createEmpno'] != null) {
		data.createEmpno = json['createEmpno'];
	}
	if (json['updateEmpno'] != null) {
		data.updateEmpno = json['updateEmpno'];
	}
	if (json['headquarterGroupId'] != null) {
		data.headquarterGroupId = json['headquarterGroupId'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['gasolineCustomerId'] != null) {
		data.gasolineCustomerId = json['gasolineCustomerId'].toString();
	}
	if (json['settlementMethod'] != null) {
		data.settlementMethod = json['settlementMethod'].toString();
	}
	if (json['settlementMethodName'] != null) {
		data.settlementMethodName = json['settlementMethodName'].toString();
	}
	if (json['totalAmount'] != null) {
		data.totalAmount = json['totalAmount'] is String
				? double.tryParse(json['totalAmount'])
				: json['totalAmount'].toDouble();
	}
	if (json['amountDetail'] != null) {
		data.amountDetail = (json['amountDetail'] as List).map((v) => CompanyInfoAmountDetail().fromJson(v)).toList();
	}
	if (json['currentMonthAmount'] != null) {
		data.currentMonthAmount = json['currentMonthAmount'] is String
				? double.tryParse(json['currentMonthAmount'])
				: json['currentMonthAmount'].toDouble();
	}
	if (json['currentMonthOrderQuantity'] != null) {
		data.currentMonthOrderQuantity = json['currentMonthOrderQuantity'] is String
				? double.tryParse(json['currentMonthOrderQuantity'])
				: json['currentMonthOrderQuantity'].toDouble();
	}
	if (json['isAdmin'] != null) {
		data.isAdmin = json['isAdmin'];
	}
	if (json['code'] != null) {
		data.code = json['code'].toString();
	}
	if (json['warnAmount'] != null) {
		data.warnAmount = json['warnAmount'] is String
				? double.tryParse(json['warnAmount'])
				: json['warnAmount'].toDouble();
	}
	if (json['ifWarnSwitch'] != null) {
		data.ifWarnSwitch = json['ifWarnSwitch'] is String
				? int.tryParse(json['ifWarnSwitch'])
				: json['ifWarnSwitch'].toInt();
	}
	return data;
}

Map<String, dynamic> companyInfoEntityToJson(CompanyInfoEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['createTime'] = entity.createTime;
	data['createUser'] = entity.createUser;
	data['createUserId'] = entity.createUserId;
	data['updateTime'] = entity.updateTime;
	data['updateUser'] = entity.updateUser;
	data['updateUserId'] = entity.updateUserId;
	data['createEmpno'] = entity.createEmpno;
	data['updateEmpno'] = entity.updateEmpno;
	data['headquarterGroupId'] = entity.headquarterGroupId;
	data['name'] = entity.name;
	data['gasolineCustomerId'] = entity.gasolineCustomerId;
	data['settlementMethod'] = entity.settlementMethod;
	data['settlementMethodName'] = entity.settlementMethodName;
	data['totalAmount'] = entity.totalAmount;
	data['amountDetail'] =  entity.amountDetail?.map((v) => v.toJson())?.toList();
	data['currentMonthAmount'] = entity.currentMonthAmount;
	data['currentMonthOrderQuantity'] = entity.currentMonthOrderQuantity;
	data['isAdmin'] = entity.isAdmin;
	data['code'] = entity.code;
	data['warnAmount'] = entity.warnAmount;
	data['ifWarnSwitch'] = entity.ifWarnSwitch;
	return data;
}

companyInfoAmountDetailFromJson(CompanyInfoAmountDetail data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['amount'] != null) {
		data.amount = json['amount'] is String
				? double.tryParse(json['amount'])
				: json['amount'].toDouble();
	}
	return data;
}

Map<String, dynamic> companyInfoAmountDetailToJson(CompanyInfoAmountDetail entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['type'] = entity.type;
	data['amount'] = entity.amount;
	return data;
}